﻿@page
@inject AlbumCollection ac
@model IndexModel
@{
    var ac = Model.ac;
    ViewData["Title"] = "Albums";
    ViewData["Description"] = $"My photo gallery with {ac.Albums.Count} albums";
    ViewData["Image"] = Request.Scheme + "://" + Request.Host + ac.Albums.FirstOrDefault()?.CoverPhoto?.GetThumbnailLink((int)ImageType.Full, out int h);
}
<form id="admin" if-authorized method="post" action="~/album/new/create/">
    <input type="text" name="name" id="name" aria-label="Album name" placeholder="相册名称" required />
    <input type="submit" id="newalbum" data-progress="Creating..." value="新建相册">
</form>
@if (!User.Identity.IsAuthenticated)
{
    <p>请先<a asp-page="Login">登录</a>才能上次照片</p>

}
@if (ac.Albums.Count == 0)
{
    <p>尚未建立相簿,请先创建相簿才能上传照片.</p>
}
<div class="albumlist pic">
    @{
        foreach (Album album in ac.Albums)
        {
            var photo = album.CoverPhoto;
            if (photo != null)
            {
                <a href="/album/@album.UrlName/" data-text="@album.Name (@album.Photos.Count)">
                    <img photo="@photo" type="Thumbnail" />
                </a>
            }
            else
            {
                <a href="/album/@album.UrlName/" data-text="@album.Name">
                </a>
            }
        }
    }
</div>
@section head {
    <link if-authorized rel="stylesheet" href="~/css/admin.scss" />
}
@section scripts {
    <script if-authorized src="~/js/admin.js" async></script>
}
